
import java.util.Arrays;
public class Secelt
{
   public static void main(String[] args){
       int[]arr1=new int[]{1,2,45,22,23,8978,34,35,566,23,55,243};
       int[]arr2=new int[]{1,2,45,22,23,8978,34,35,566,23,55,243};
       System.out.println("排序前:");
       show(arr1);
        System.out.println("");
       ss3(arr1); 
       System.out.println("maopao hou:");
      show(arr1);
        System.out.println("");
        ss2(arr2);
       System.out.println("xuanzhe hou:");
       show(arr2);
    }
    //冒泡
    public static void ss1(int arr[]){
        for(int i =0;i<arr.length-1;i++){
        for(int j=0;j<arr.length-1-i;j++){
            if(arr[j]>arr[j+1]){
            int min = arr[j+1];
            arr[j+1]=arr[j];
            arr[j]=min;
            }
        
        
        }
    }}
    //选择
   public static void ss2(int arr[]){
        for(int i =0;i<arr.length-1;i++){
            int min=arr[i];
            int minindex=i;
        for(int j=i+1;j<arr.length;j++){
            if(arr[j]<min){
            min=arr[j];
            minindex=j;
            }
        }
           if(i!=minindex){
               
               arr[minindex]=arr[i];
               arr[i]=min;
            
            }
        }
    }
   public static void show(int arr[]){
       System.out.print("[");
    for(int e:arr){
        if(e!=arr[arr.length-1]){
           System.out.print(e+",");
        }else{
            System.out.print(e);
        }
        }
    System.out.print("]");
    }
    public static void ss3(int arr[]){
    Arrays.sort(arr);
    
    }
}
